home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / ostream.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  32.9 KB  |  1,499 lines

  1. #ifndef __OSTREAM_CC
  2. #define __OSTREAM_CC
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * ostream.cc - Definitions for the Standard Library ostream classes
  8.  *
  9.  * $Id: ostream.cc,v 1.78 1996/09/24 00:41:58 philippe Exp $
  10.  *
  11.  ***************************************************************************
  12.  *
  13.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  14.  * ALL RIGHTS RESERVED *
  15.  * The software and information contained herein are proprietary to, and
  16.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  17.  * intends to preserve as trade secrets such software and information.
  18.  * This software is furnished pursuant to a written license agreement and
  19.  * may be used, copied, transmitted, and stored only in accordance with
  20.  * the terms of such license and with the inclusion of the above copyright
  21.  * notice.  This software and information or any other copies thereof may
  22.  * not be provided or otherwise made available to any other person.
  23.  *
  24.  * Notwithstanding any other lease or license that may pertain to, or
  25.  * accompany the delivery of, this computer software and information, the
  26.  * rights of the Government regarding its use, reproduction and disclosure
  27.  * are as set forth in Section 52.227-19 of the FARS Computer
  28.  * Software-Restricted Rights clause.
  29.  * 
  30.  * Use, duplication, or disclosure by the Government is subject to
  31.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  32.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  33.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  34.  * P.O. Box 2328, Corvallis, Oregon 97339.
  35.  *
  36.  * This computer software and information is distributed with "restricted
  37.  * rights."  Use, duplication or disclosure is subject to restrictions as
  38.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  39.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  40.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  41.  * then the "Alternate III" clause applies.
  42.  *
  43.  **************************************************************************/
  44.  
  45. #include <streambuf>
  46.  
  47. #ifndef _RWSTD_NO_NAMESPACE
  48. namespace std {
  49. #endif
  50.  
  51. /*
  52.  * basic_ostream(basic_streambuf *)
  53.  */
  54.  
  55. template<class charT, class traits> 
  56. basic_ostream<charT, traits>::basic_ostream(basic_streambuf<charT, traits> *sb)
  57. {
  58.   if ( sb )
  59.    {
  60.      if ( sb->which_open_mode() & ios_base::out ) 
  61.        init(sb);
  62.      else
  63.        init(0);
  64.    } 
  65.   else
  66.    init(0);
  67. }
  68.  
  69. /*
  70.  * basic_ostream( )
  71.  */
  72.  
  73. template<class charT, class traits>
  74. basic_ostream<charT, traits>::basic_ostream( )
  75. {
  76. }
  77.  
  78.  
  79. /*
  80.  * ~basic_ostream()
  81.  */
  82.  
  83. template<class charT, class traits>
  84. basic_ostream<charT, traits>::~basic_ostream()
  85. {
  86.  
  87. }
  88.  
  89. /*
  90.  * basic_ostream& flush()  
  91.  */
  92.  
  93. template<class charT, class traits>
  94. basic_ostream<charT, traits>&
  95. basic_ostream<charT, traits>::flush()
  96. {
  97.   
  98.  if(rdbuf()) {
  99.  
  100.   #ifdef _RWSTD_MULTI_THREAD
  101.     _RWSTDGuard guard(this->rdbuf()->buffer_mutex_);
  102.   #endif
  103.  
  104.  
  105.        if(rdbuf()->pubsync() == -1)
  106.         this->setstate(ios_base::badbit);
  107.   }
  108.  
  109.   return *this;
  110. }
  111.   
  112. /*
  113.  * basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&))
  114.  *
  115.  * these are the ostream manipulators (endl, ends, flush)
  116.  */
  117.  
  118. template<class charT, class traits>
  119. basic_ostream<charT, traits>&
  120. basic_ostream<charT, traits>::
  121. operator<<(basic_ostream<charT, traits>& (*pf)(basic_ostream<charT, traits>& ))
  122. {
  123.   return (*pf)(*this);
  124. }
  125.  
  126.  
  127.  
  128. /*
  129.  * basic_ostream& operator<<(ios_base& (*pf)(ios_base&))
  130.  *
  131.  * outputs the ios_base manipulators
  132.  */
  133.  
  134. template<class charT, class traits>
  135. basic_ostream<charT, traits>&
  136. basic_ostream<charT, traits>::
  137. operator<<(ios_base& (*pf)(ios_base&))
  138. {
  139.   (*pf)(*this);
  140.  
  141.   return *this;
  142. }
  143.  
  144. /*
  145.  * basic_ostream& operator<<(basic_ios& (*pf)(basic_ios& ))
  146.  *
  147.  * these are the ios manipulators (dec, hex, ...)
  148.  */
  149.  
  150. template<class charT, class traits>
  151. basic_ostream<charT, traits>&
  152. basic_ostream<charT, traits>::
  153. operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&))
  154. {
  155.   (*pf)(*this);
  156.  
  157.   return *this;
  158. }
  159.  
  160. /*
  161.  * basic_ostream& operator<< (basic_ostream<charT, traits>& os, const charT *)
  162.  *
  163.  */
  164.  
  165. template<class charT, class traits>
  166. basic_ostream<charT, traits>&
  167. _RWSTDExport operator<< ( basic_ostream<charT, traits>& os, const charT *s)
  168. {
  169.   ios_base::iostate err = 0;
  170.  
  171.   #ifndef _RWSTD_NO_EXCEPTIONS
  172.   try {
  173.   #endif
  174.   
  175.    if ( s ) {   
  176.     _TYPENAME basic_ostream<charT, traits>::sentry opfx(os);
  177.     if (opfx)
  178.      {
  179.        int   dlen = traits::length(s);
  180.        int   pad = os.width() - dlen;
  181.  
  182.        // place right padding
  183.        if( os.flags() & ios_base::right ) {
  184.         while(--pad >= 0) {
  185.           if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  186.             err = ios_base::badbit;
  187.             break;
  188.            }
  189.           }
  190.          }
  191.      
  192.      // output internal padding
  193.      if(os.good() && (os.flags() & ios_base::internal)) {
  194.           while(--pad >= 0) {
  195.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  196.             err = ios_base::badbit;
  197.             break;
  198.            }
  199.           }
  200.          }
  201.  
  202.      if(os.good() && dlen) {
  203.           if(os.rdbuf() && (os.rdbuf()->sputn(s, dlen) != dlen))
  204.            err = ios_base::badbit;
  205.           }
  206.  
  207.          // output left padding. 
  208.          if(os.good() && (os.flags() & ios_base::left)) {
  209.           while(--pad >= 0) {
  210.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  211.              err = ios_base::badbit;
  212.              break;
  213.             }
  214.            }
  215.           }
  216.  
  217.        os.width(0);
  218.      }
  219.     }
  220.    else
  221.     err = ios_base::badbit;
  222.  
  223.   #ifndef _RWSTD_NO_EXCEPTIONS
  224.   }
  225.   #endif
  226.  
  227.   #ifndef _RWSTD_NO_EXCEPTIONS
  228.   catch(...)
  229.   {
  230.     bool flag = false;
  231.     try {
  232.            os.setstate(ios_base::badbit);
  233.         }
  234.     catch( ios_base::failure ) { flag= true; }
  235.     if ( flag ) throw;
  236.   }
  237.   #endif
  238.  
  239.   if ( err ) os.setstate(err);  
  240.  
  241.   return os;
  242. }
  243.  
  244.  
  245. /*
  246.  * basic_ostream& operator<< (basic_ostream<charT, traits>& os, const char *)
  247.  *
  248.  */
  249. #ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  250.  
  251. template<class charT, class traits>
  252. basic_ostream<charT, traits>&
  253. _RWSTDExport operator<< ( basic_ostream<charT, traits>& os, const char *s)
  254. {
  255.   ios_base::iostate err = 0;
  256.  
  257.   #ifndef _RWSTD_NO_EXCEPTIONS
  258.   try {
  259.   #endif
  260.   
  261.    if ( s ) {   
  262.     _TYPENAME basic_ostream<charT, traits>::sentry opfx(os);
  263.     if (opfx)
  264.      {
  265.        int   dlen = char_traits<char>::length(s);
  266.        int   pad = os.width() - dlen;
  267.  
  268.        #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  269.         const ctype<charT>& ct = use_facet< ctype<charT> >(os.getloc());
  270.        #else
  271.         const ctype<charT>& ct = use_facet(os.getloc(),(ctype<charT>*)0);
  272.        #endif
  273.  
  274.        // place right padding
  275.        if( os.flags() & ios_base::right ) {
  276.         while(--pad >= 0) {
  277.           if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  278.             err = ios_base::badbit;
  279.             break;
  280.            }
  281.           }
  282.          }
  283.      
  284.      // output internal padding
  285.      if(os.good() && (os.flags() & ios_base::internal)) {
  286.           while(--pad >= 0) {
  287.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  288.             err = ios_base::badbit;
  289.             break;
  290.            }
  291.           }
  292.          }
  293.  
  294.      if(os.good() && dlen) {
  295.            while ( dlen )
  296.             {
  297.              if( traits::eq_int_type(
  298.                     os.rdbuf()->sputc(ct.widen(*s)),
  299.                     traits::eof())) 
  300.                { 
  301.                  err = ios_base::badbit;    
  302.                }
  303.               s++;
  304.               dlen --;
  305.             }
  306.           }
  307.  
  308.          // output left padding. 
  309.          if(os.good() && (os.flags() & ios_base::left)) {
  310.           while(--pad >= 0) {
  311.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  312.              err = ios_base::badbit;
  313.              break;
  314.             }
  315.            }
  316.           }
  317.  
  318.        os.width(0);
  319.      }
  320.     }
  321.    else
  322.     err = ios_base::badbit;
  323.  
  324.   #ifndef _RWSTD_NO_EXCEPTIONS
  325.   }
  326.   #endif
  327.  
  328.   #ifndef _RWSTD_NO_EXCEPTIONS
  329.   catch(...)
  330.   {
  331.     bool flag = false;
  332.     try {
  333.            os.setstate(ios_base::badbit);
  334.         }
  335.     catch( ios_base::failure ) { flag= true; }
  336.     if ( flag ) throw;
  337.   }
  338.   #endif
  339.  
  340.   if ( err ) os.setstate(err);  
  341.  
  342.   return os;
  343. }
  344. #endif
  345.  
  346. /*
  347.  * basic_ostream& operator<< (basic_ostream<char, traits>& os, const char *)
  348.  *
  349.  */
  350.  
  351. #ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  352.  
  353. #ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC
  354. template<class traits>
  355. basic_ostream<char, traits>&
  356. _RWSTDExport operator<< ( basic_ostream<char, traits>& os, const char *s)
  357. {
  358.   ios_base::iostate err = 0;
  359.  
  360.   #ifndef _RWSTD_NO_EXCEPTIONS
  361.   try {
  362.   #endif
  363.   
  364.    if ( s ) {   
  365.     _TYPENAME basic_ostream<char, traits>::sentry opfx(os);
  366.     if (opfx)
  367.      {
  368.        int   dlen = traits::length(s);
  369.        int   pad = os.width() - dlen;
  370.  
  371.        // place right padding
  372.        if( os.flags() & ios_base::right ) {
  373.         while(--pad >= 0) {
  374.           if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  375.             err = ios_base::badbit;
  376.             break;
  377.            }
  378.           }
  379.          }
  380.      
  381.      // output internal padding
  382.      if(os.good() && (os.flags() & ios_base::internal)) {
  383.           while(--pad >= 0) {
  384.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  385.             err = ios_base::badbit;
  386.             break;
  387.            }
  388.           }
  389.          }
  390.  
  391.      if(os.good() && dlen) {
  392.           if(os.rdbuf() && (os.rdbuf()->sputn(s, dlen) != dlen))
  393.            err = ios_base::badbit;
  394.           }
  395.  
  396.          // output left padding. 
  397.          if(os.good() && (os.flags() & ios_base::left)) {
  398.           while(--pad >= 0) {
  399.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  400.              err = ios_base::badbit;
  401.              break;
  402.             }
  403.            }
  404.           }
  405.  
  406.        os.width(0);
  407.      }
  408.     }
  409.    else
  410.     err = ios_base::badbit;
  411.  
  412.   #ifndef _RWSTD_NO_EXCEPTIONS
  413.   }
  414.   #endif
  415.  
  416.   #ifndef _RWSTD_NO_EXCEPTIONS
  417.   catch(...)
  418.   {
  419.     bool flag = false;
  420.     try {
  421.            os.setstate(ios_base::badbit);
  422.         }
  423.     catch( ios_base::failure ) { flag= true; }
  424.     if ( flag ) throw;
  425.   }
  426.   #endif
  427.  
  428.   if ( err ) os.setstate(err);  
  429.  
  430.   return os;
  431. }
  432. #endif
  433. #endif
  434.  
  435. /*
  436.  * basic_ostream& operator<<( basic_ostream<charT, traits>&, charT )
  437.  *
  438.  */
  439.  
  440. template<class charT, class traits>
  441. basic_ostream<charT, traits>&
  442. _RWSTDExport operator<< (basic_ostream<charT, traits>& os, charT c)
  443. {
  444.   ios_base::iostate err = 0;
  445.  
  446.   #ifndef _RWSTD_NO_EXCEPTIONS
  447.   try {
  448.   #endif
  449.  
  450.     _TYPENAME basic_ostream<charT, traits>::sentry opfx(os); 
  451.  
  452.     if(opfx) 
  453.     {
  454.        int   pad = os.width() - 1;
  455.  
  456.        // place right padding
  457.        if( os.flags() & ios_base::right ) {
  458.         while(--pad >= 0) {
  459.           if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  460.             err = ios_base::badbit;
  461.             break;
  462.            }
  463.           }
  464.          }
  465.      
  466.      // output internal padding
  467.      if(os.good() && (os.flags() & ios_base::internal)) {
  468.           while(--pad >= 0) {
  469.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  470.             err = ios_base::badbit;
  471.             break;
  472.            }
  473.           }
  474.          }
  475.  
  476.      if(os.good()) {
  477.            if( traits::eq_int_type(os.rdbuf()->sputc(c),traits::eof())) 
  478.             err = ios_base::badbit;    
  479.          }
  480.  
  481.          // output left padding. 
  482.          if(os.good() && (os.flags() & ios_base::left)) {
  483.           while(--pad >= 0) {
  484.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  485.              err = ios_base::badbit;
  486.              break;
  487.             }
  488.            }
  489.           }
  490.  
  491.        os.width(0);
  492.      
  493.      }
  494.  
  495.   #ifndef _RWSTD_NO_EXCEPTIONS
  496.   }
  497.   #endif
  498.  
  499.   #ifndef _RWSTD_NO_EXCEPTIONS
  500.   catch(...)
  501.   {
  502.     bool flag = false;
  503.     try {
  504.            os.setstate(ios_base::failbit);
  505.         }
  506.     catch( ios_base::failure ) { flag= true; }
  507.     if ( flag ) throw;
  508.   }
  509.   #endif
  510.  
  511.   if ( err ) os.setstate(err); 
  512.  
  513.   return os;
  514. }
  515.  
  516. /*
  517.  * basic_ostream& operator<<( basic_ostream<charT, traits>&, char )
  518.  *
  519.  */
  520.  
  521. #ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  522.  
  523. template<class charT, class traits>
  524. basic_ostream<charT, traits>&
  525. _RWSTDExport operator<< (basic_ostream<charT, traits>& os, char c)
  526. {
  527.   ios_base::iostate err = 0;
  528.  
  529.   #ifndef _RWSTD_NO_EXCEPTIONS
  530.   try {
  531.   #endif
  532.  
  533.     _TYPENAME basic_ostream<charT, traits>::sentry opfx(os); 
  534.  
  535.     if(opfx) 
  536.     {
  537.      #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  538.       const ctype<charT>& ct = use_facet< ctype<charT> >(os.getloc());
  539.      #else
  540.       const ctype<charT>& ct = use_facet(os.getloc(),(ctype<charT>*)0);
  541.      #endif
  542.  
  543.      int   pad = os.width() - 1;
  544.  
  545.        // place right padding
  546.        if( os.flags() & ios_base::right ) {
  547.         while(--pad >= 0) {
  548.           if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  549.             err = ios_base::badbit;
  550.             break;
  551.            }
  552.           }
  553.          }
  554.      
  555.      // output internal padding
  556.      if(os.good() && (os.flags() & ios_base::internal)) {
  557.           while(--pad >= 0) {
  558.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  559.             err = ios_base::badbit;
  560.             break;
  561.            }
  562.           }
  563.          }
  564.  
  565.      if(os.good()) {
  566.            if( traits::eq_int_type(os.rdbuf()->sputc(ct.widen(c)),traits::eof())) 
  567.             err = ios_base::badbit;      
  568.          }
  569.  
  570.          // output left padding. 
  571.          if(os.good() && (os.flags() & ios_base::left)) {
  572.           while(--pad >= 0) {
  573.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  574.              err = ios_base::badbit;
  575.              break;
  576.             }
  577.            }
  578.           }
  579.  
  580.        os.width(0);    
  581.   
  582.      }
  583.  
  584.   #ifndef _RWSTD_NO_EXCEPTIONS
  585.   }
  586.   #endif
  587.  
  588.   #ifndef _RWSTD_NO_EXCEPTIONS
  589.   catch(...)
  590.   {
  591.     bool flag = false;
  592.     try {
  593.            os.setstate(ios_base::failbit);
  594.         }
  595.     catch( ios_base::failure ) { flag= true; }
  596.     if ( flag ) throw;
  597.   }
  598.   #endif
  599.  
  600.   if ( err ) os.setstate(err); 
  601.  
  602.   return os;
  603. }
  604. #endif
  605.  
  606. /*
  607.  * basic_ostream& operator<<( basic_ostream<char, traits>&, char )
  608.  *
  609.  */
  610.  
  611. #ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
  612.  
  613. #ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC
  614. template<class traits>
  615. basic_ostream<char, traits>&
  616. _RWSTDExport operator<< (basic_ostream<char, traits>& os, char c)
  617. {
  618.   ios_base::iostate err = 0;
  619.  
  620.   #ifndef _RWSTD_NO_EXCEPTIONS
  621.   try {
  622.   #endif
  623.  
  624.     _TYPENAME basic_ostream<char, traits>::sentry opfx(os); 
  625.  
  626.     if(opfx) 
  627.     {
  628.        int   pad = os.width() - 1;
  629.  
  630.        // place right padding
  631.        if( os.flags() & ios_base::right ) {
  632.         while(--pad >= 0) {
  633.           if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  634.             err = ios_base::badbit;
  635.             break;
  636.            }
  637.           }
  638.          }
  639.      
  640.      // output internal padding
  641.      if(os.good() && (os.flags() & ios_base::internal)) {
  642.           while(--pad >= 0) {
  643.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  644.             err = ios_base::badbit;
  645.             break;
  646.            }
  647.           }
  648.          }
  649.  
  650.      if(os.good()) {
  651.             if( traits::eq_int_type(os.rdbuf()->sputc(c),traits::eof())) 
  652.              err = ios_base::badbit;       
  653.          }
  654.  
  655.          // output left padding. 
  656.          if(os.good() && (os.flags() & ios_base::left)) {
  657.           while(--pad >= 0) {
  658.            if( traits::eq_int_type(os.rdbuf()->sputc(os.fill()),traits::eof())) {
  659.              err = ios_base::badbit;
  660.              break;
  661.             }
  662.            }
  663.           }
  664.  
  665.        os.width(0);    
  666.       
  667.      }
  668.  
  669.   #ifndef _RWSTD_NO_EXCEPTIONS
  670.   }
  671.   #endif
  672.  
  673.   #ifndef _RWSTD_NO_EXCEPTIONS
  674.   catch(...)
  675.   {
  676.     bool flag = false;
  677.     try {
  678.            os.setstate(ios_base::failbit);
  679.         }
  680.     catch( ios_base::failure ) { flag= true; }
  681.     if ( flag ) throw;
  682.   }
  683.   #endif
  684.  
  685.   if ( err ) os.setstate(err); 
  686.  
  687.   return os;
  688. }
  689. #endif
  690. #endif
  691.  
  692. #ifndef _RWSTD_NO_SIGNED_CHAR_IN_STREAMS
  693. /*
  694.  * ostream& operator<<(basic_ostream<char,traits>&,unsigned char )
  695.  *
  696.  */
  697.  
  698. template <class traits>
  699. basic_ostream<char, traits>&
  700. _RWSTDExport operator<<(basic_ostream<char, traits>& os,unsigned char uc)
  701. {
  702.  
  703.   return (os << (char)uc);
  704. }
  705.  
  706. /*
  707.  * ostream& operator<<(basic_ostream<char, traits>&,signed char )
  708.  *
  709.  */
  710.  
  711. template <class traits>
  712. basic_ostream<char, traits>&
  713. _RWSTDExport operator<<(basic_ostream<char, traits>& os,signed char sc)
  714. {
  715.  
  716.   return (os << (char)sc);
  717. }
  718.  
  719. /*
  720.  * ostream& operator<<(basic_ostream<char, traits>&,const unsigned char* )
  721.  *
  722.  */
  723.  
  724. template <class traits>
  725. basic_ostream<char, traits>&
  726. _RWSTDExport operator<<(basic_ostream<char, traits>& os,const unsigned char* uc)
  727. {
  728.  
  729.   return (os << (char *)uc);
  730. }
  731.  
  732. /*
  733.  * ostream& operator<<(basic_ostream<char, traits>&,const signed char* )
  734.  *
  735.  */
  736.  
  737. template <class traits>
  738. basic_ostream<char, traits>&
  739. _RWSTDExport operator<<(basic_ostream<char, traits>& os,const signed char* sc)
  740. {
  741.  
  742.   return (os << (char *)sc);
  743. }
  744. #endif
  745.  
  746.  
  747. /*
  748.  * basic_ostream& operator<<(bool n)
  749.  */
  750.  
  751. #ifndef _RWSTD_NO_BOOL
  752.  
  753. template<class charT, class traits>
  754. basic_ostream<charT, traits>&
  755. basic_ostream<charT, traits>::operator<<(bool n)
  756. {
  757.   ios_base::iostate err = 0;
  758.  
  759.   #ifndef _RWSTD_NO_EXCEPTIONS
  760.   try {
  761.   #endif
  762.  
  763.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  764.   if (opfx)
  765.   {
  766.     if (
  767.     #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  768.     use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  769.     #else
  770.     use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  771.     #endif
  772.       .put(ostreambuf_iterator<charT,traits>(*this),*this,this->fill(),n).failed() )
  773.       err = ios_base::badbit;
  774.     this->width(0);
  775.   }
  776.  
  777.   #ifndef _RWSTD_NO_EXCEPTIONS
  778.   }
  779.   #endif
  780.  
  781.   #ifndef _RWSTD_NO_EXCEPTIONS
  782.   catch(...)
  783.   {
  784.     bool flag = false;
  785.     try {
  786.            this->setstate(ios_base::badbit);
  787.         }
  788.     catch( ios_base::failure ) { flag= true; }
  789.     if ( flag ) throw;
  790.   }
  791.   #endif
  792.  
  793.   if ( err ) this->setstate(err);
  794.  
  795.   return *this;
  796. }
  797.  
  798. #endif
  799.  
  800. /*
  801.  * basic_ostream& operator<<(short)
  802.  */
  803.  
  804. template<class charT, class traits>
  805. basic_ostream<charT, traits>&
  806. basic_ostream<charT, traits>::operator<<(short n)
  807. {
  808.   ios_base::iostate err = 0;
  809.  
  810.   #ifndef _RWSTD_NO_EXCEPTIONS
  811.   try {
  812.   #endif  
  813.  
  814.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  815.   if (opfx)
  816.   {
  817.    if (
  818.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  819.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  820.    #else
  821.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  822.    #endif
  823.      .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  824.       err = ios_base::badbit;
  825.  
  826.   this->width(0);
  827.  
  828.   }
  829.  
  830.   #ifndef _RWSTD_NO_EXCEPTIONS
  831.   }
  832.   #endif
  833.  
  834.   #ifndef _RWSTD_NO_EXCEPTIONS
  835.   catch(...)
  836.   {
  837.     bool flag = false;
  838.     try {
  839.            this->setstate(ios_base::badbit);
  840.         }
  841.     catch( ios_base::failure ) { flag= true; }
  842.     if ( flag ) throw;
  843.   }
  844.   #endif
  845.  
  846.   if ( err ) this->setstate(err);
  847.  
  848.   return *this;
  849. }
  850.  
  851. /*
  852.  * basic_ostream& operator<<(unsigned short)
  853.  */
  854.  
  855. template<class charT, class traits>
  856. basic_ostream<charT, traits>&
  857. basic_ostream<charT, traits>::operator<<(unsigned short n)
  858. {
  859.   ios_base::iostate err = 0;
  860.  
  861.   #ifndef _RWSTD_NO_EXCEPTIONS
  862.   try {
  863.   #endif  
  864.  
  865.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  866.   if (opfx)
  867.   {
  868.    if (
  869.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  870.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  871.    #else
  872.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  873.    #endif
  874.     .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  875.       err = ios_base::badbit;
  876.  
  877.   this->width(0);
  878.  
  879.   }
  880.  
  881.   #ifndef _RWSTD_NO_EXCEPTIONS
  882.   }
  883.   #endif
  884.  
  885.   #ifndef _RWSTD_NO_EXCEPTIONS
  886.   catch(...)
  887.   {
  888.     bool flag = false;
  889.     try {
  890.            this->setstate(ios_base::badbit);
  891.         }
  892.     catch( ios_base::failure ) { flag= true; }
  893.     if ( flag ) throw;
  894.   }
  895.   #endif
  896.  
  897.   if ( err ) this->setstate(err);
  898.  
  899.   return *this; 
  900. }
  901.  
  902. /*
  903.  * basic_ostream& operator<<(int)
  904.  */
  905.  
  906. template<class charT, class traits>
  907. basic_ostream<charT, traits>&
  908. basic_ostream<charT, traits>::operator<<(int n)
  909. {
  910.   ios_base::iostate err = 0;
  911.  
  912.   #ifndef _RWSTD_NO_EXCEPTIONS
  913.   try {
  914.   #endif  
  915.  
  916.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  917.   if (opfx)
  918.   {
  919.    if ( 
  920.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  921.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  922.    #else
  923.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  924.    #endif
  925.      .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  926.        err = ios_base::badbit;
  927.    
  928.    this->width(0);
  929.   
  930.   }
  931.  
  932.   #ifndef _RWSTD_NO_EXCEPTIONS
  933.   }
  934.   #endif
  935.  
  936.   #ifndef _RWSTD_NO_EXCEPTIONS
  937.   catch(...)
  938.   {
  939.     bool flag = false;
  940.     try {
  941.            this->setstate(ios_base::badbit);
  942.         }
  943.     catch( ios_base::failure ) { flag= true; }
  944.     if ( flag ) throw;
  945.   }
  946.   #endif
  947.  
  948.   if ( err ) this->setstate(err);  
  949.  
  950.   return *this; 
  951. }
  952. /*
  953.  * basic_ostream& operator<<(unsigned int)
  954.  */
  955.  
  956. template<class charT, class traits>
  957. basic_ostream<charT, traits>&
  958. basic_ostream<charT, traits>::operator<<(unsigned int n)
  959. {
  960.   ios_base::iostate err = 0;
  961.  
  962.   #ifndef _RWSTD_NO_EXCEPTIONS
  963.   try {
  964.   #endif 
  965.  
  966.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  967.   if (opfx)
  968.   {
  969.    if (
  970.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  971.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  972.    #else
  973.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  974.    #endif
  975.      .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  976.        err = ios_base::badbit;
  977.     
  978.   this->width(0);
  979.  
  980.   }
  981.  
  982.   #ifndef _RWSTD_NO_EXCEPTIONS
  983.   }
  984.   #endif
  985.  
  986.   #ifndef _RWSTD_NO_EXCEPTIONS
  987.   catch(...)
  988.   {
  989.     bool flag = false;
  990.     try {
  991.            this->setstate(ios_base::badbit);
  992.         }
  993.     catch( ios_base::failure ) { flag= true; }
  994.     if ( flag ) throw;
  995.   }
  996.   #endif
  997.  
  998.   if ( err ) this->setstate(err);
  999.  
  1000.   return *this; 
  1001. }
  1002.  
  1003.  
  1004. /*
  1005.  * basic_ostream& operator<<(long)
  1006.  */
  1007.  
  1008. template<class charT, class traits>
  1009. basic_ostream<charT, traits>&
  1010. basic_ostream<charT, traits>::operator<<(long n)
  1011. {
  1012.   ios_base::iostate err = 0;
  1013.  
  1014.   #ifndef _RWSTD_NO_EXCEPTIONS
  1015.   try {
  1016.   #endif
  1017.  
  1018.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1019.   if (opfx)
  1020.   {
  1021.    if (
  1022.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1023.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1024.    #else
  1025.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1026.    #endif
  1027.      .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1028.        err = ios_base::badbit;
  1029.    
  1030.    width(0);
  1031.  
  1032.   } 
  1033.  
  1034.   #ifndef _RWSTD_NO_EXCEPTIONS
  1035.   }
  1036.   #endif
  1037.  
  1038.   #ifndef _RWSTD_NO_EXCEPTIONS
  1039.   catch(...)
  1040.   {
  1041.     bool flag = false;
  1042.     try {
  1043.            this->setstate(ios_base::badbit);
  1044.         }
  1045.     catch( ios_base::failure ) { flag= true; }
  1046.     if ( flag ) throw;
  1047.   }
  1048.   #endif
  1049.  
  1050.   if ( err ) this->setstate(err);
  1051.  
  1052.   return *this; 
  1053. }
  1054.  
  1055. /*
  1056.  * basic_ostream& operator<<(unsigned long)
  1057.  */
  1058.  
  1059. template<class charT, class traits>
  1060. basic_ostream<charT, traits>&
  1061. basic_ostream<charT, traits>::operator<<(unsigned long n)
  1062. {
  1063.   ios_base::iostate err = 0;
  1064.  
  1065.   #ifndef _RWSTD_NO_EXCEPTIONS
  1066.   try {
  1067.   #endif
  1068.  
  1069.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1070.   if (opfx)
  1071.   {
  1072.    if (
  1073.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1074.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1075.    #else
  1076.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1077.    #endif
  1078.      .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1079.        err = ios_base::badbit;
  1080.    
  1081.    this->width(0);
  1082.  
  1083.   }
  1084.  
  1085.   #ifndef _RWSTD_NO_EXCEPTIONS
  1086.   }
  1087.   #endif
  1088.  
  1089.   #ifndef _RWSTD_NO_EXCEPTIONS
  1090.   catch(...)
  1091.   {
  1092.     bool flag = false;
  1093.     try {
  1094.            this->setstate(ios_base::badbit);
  1095.         }
  1096.     catch( ios_base::failure ) { flag= true; }
  1097.     if ( flag ) throw;
  1098.   }
  1099.   #endif
  1100.  
  1101.    if ( err ) this->setstate(err);
  1102.  
  1103.   return *this; 
  1104. }
  1105.  
  1106.  
  1107. /*
  1108.  * basic_ostream& operator<<(float)
  1109.  */
  1110.  
  1111. template<class charT, class traits>
  1112. basic_ostream<charT, traits>&
  1113. basic_ostream<charT, traits>::operator<<(float n)
  1114. {
  1115.   ios_base::iostate err = 0;
  1116.  
  1117.   #ifndef _RWSTD_NO_EXCEPTIONS
  1118.   try {
  1119.   #endif
  1120.  
  1121.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1122.   if (opfx)
  1123.   {
  1124.    if (
  1125.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1126.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1127.    #else
  1128.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1129.    #endif
  1130.      .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),(double)n).failed() )
  1131.     err = ios_base::badbit;
  1132.    this->width(0);
  1133.   }
  1134.  
  1135.   #ifndef _RWSTD_NO_EXCEPTIONS
  1136.   }
  1137.   #endif
  1138.  
  1139.   #ifndef _RWSTD_NO_EXCEPTIONS
  1140.   catch(...)
  1141.   {
  1142.     bool flag = false;
  1143.     try {
  1144.            this->setstate(ios_base::badbit);
  1145.         }
  1146.     catch( ios_base::failure ) { flag= true; }
  1147.     if ( flag ) throw;
  1148.   }
  1149.   #endif
  1150.  
  1151.   if ( err ) this->setstate(err);
  1152.  
  1153.   return *this;
  1154. }
  1155.  
  1156. /*
  1157.  * basic_ostream& operator<<(double)
  1158.  */
  1159.  
  1160. template<class charT, class traits>
  1161. basic_ostream<charT, traits>&
  1162. basic_ostream<charT, traits>::operator<<(double n)
  1163. {
  1164.   ios_base::iostate err = 0;
  1165.  
  1166.   #ifndef _RWSTD_NO_EXCEPTIONS
  1167.   try {
  1168.   #endif
  1169.  
  1170.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1171.   if (opfx)
  1172.   {
  1173.    if (
  1174.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1175.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1176.    #else
  1177.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1178.    #endif
  1179.      .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1180.        err = ios_base::badbit;
  1181.  
  1182.   this->width(0);
  1183.  
  1184.   }
  1185.  
  1186.   #ifndef _RWSTD_NO_EXCEPTIONS
  1187.   }
  1188.   #endif
  1189.  
  1190.   #ifndef _RWSTD_NO_EXCEPTIONS
  1191.   catch(...)
  1192.   {
  1193.     bool flag = false;
  1194.     try {
  1195.            this->setstate(ios_base::badbit);
  1196.         }
  1197.     catch( ios_base::failure ) { flag= true; }
  1198.     if ( flag ) throw;
  1199.   }
  1200.   #endif
  1201.  
  1202.   if ( err ) this->setstate(err);
  1203.  
  1204.   return *this;
  1205. }
  1206.  
  1207. /*
  1208.  * basic_ostream& operator<<(long double)
  1209.  */
  1210.  
  1211. template<class charT, class traits>
  1212. basic_ostream<charT, traits>&
  1213. basic_ostream<charT, traits>::operator<<(long double n)
  1214. {
  1215.   ios_base::iostate err = 0;
  1216.  
  1217.   #ifndef _RWSTD_NO_EXCEPTIONS
  1218.   try {
  1219.   #endif
  1220.  
  1221.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1222.   if (opfx)
  1223.   {
  1224.     if (
  1225.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1226.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1227.    #else
  1228.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1229.    #endif
  1230.      .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1231.        err = ios_base::badbit;
  1232.    
  1233.   this->width(0);
  1234.  
  1235.   }
  1236.  
  1237.   #ifndef _RWSTD_NO_EXCEPTIONS
  1238.   }
  1239.   #endif
  1240.  
  1241.   #ifndef _RWSTD_NO_EXCEPTIONS
  1242.   catch(...)
  1243.   {
  1244.     bool flag = false;
  1245.     try {
  1246.            this->setstate(ios_base::badbit);
  1247.         }
  1248.     catch( ios_base::failure ) { flag= true; }
  1249.     if ( flag ) throw;
  1250.   }
  1251.   #endif
  1252.  
  1253.   if ( err ) this->setstate(err);
  1254.  
  1255.   return *this;
  1256. }
  1257.  
  1258. /*
  1259.  * basic_ostream& operator<<(_RWSTD_LONG_LONG)
  1260.  */
  1261.  
  1262. #ifdef _RWSTD_LONG_LONG
  1263.  
  1264. template<class charT, class traits>
  1265. basic_ostream<charT, traits>&
  1266. basic_ostream<charT, traits>::operator<<(_RWSTD_LONG_LONG n)
  1267. {
  1268.   ios_base::iostate err = 0;
  1269.  
  1270.   #ifndef _RWSTD_NO_EXCEPTIONS
  1271.   try {
  1272.   #endif
  1273.  
  1274.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1275.   if (opfx)
  1276.   {
  1277.     if (
  1278.    #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1279.    use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1280.    #else
  1281.    use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1282.    #endif
  1283.      .put(ostreambuf_iterator<charT,traits>(*this),*this,basic_ios<charT,traits>::fill(),n).failed() )
  1284.        err = ios_base::badbit;
  1285.    
  1286.   this->width(0);
  1287.  
  1288.   }
  1289.  
  1290.   #ifndef _RWSTD_NO_EXCEPTIONS
  1291.   }
  1292.   #endif
  1293.  
  1294.   #ifndef _RWSTD_NO_EXCEPTIONS
  1295.   catch(...)
  1296.   {
  1297.     bool flag = false;
  1298.     try {
  1299.            this->setstate(ios_base::badbit);
  1300.         }
  1301.     catch( ios_base::failure ) { flag= true; }
  1302.     if ( flag ) throw;
  1303.   }
  1304.   #endif
  1305.  
  1306.   if ( err ) this->setstate(err);
  1307.  
  1308.   return *this;
  1309. }
  1310. #endif //_RWSTD_LONG_LONG
  1311.  
  1312. /*
  1313.  * basic_ostream& operator<<(void *)
  1314.  */
  1315.  
  1316. template<class charT, class traits>
  1317. basic_ostream<charT, traits>&
  1318. basic_ostream<charT, traits>::operator<<(void *p)
  1319. {
  1320.   ios_base::iostate err = 0;
  1321.  
  1322.   #ifndef _RWSTD_NO_EXCEPTIONS
  1323.   try {
  1324.   #endif
  1325.  
  1326.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1327.   if (opfx)
  1328.   {
  1329.     if (
  1330.     #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  1331.     use_facet<num_put<charT,ostreambuf_iterator<charT,traits> > >(this->getloc())
  1332.     #else
  1333.     use_facet(this->getloc(),(num_put<charT,ostreambuf_iterator<charT,traits> >*)0)
  1334.     #endif
  1335.       .put(ostreambuf_iterator<charT,traits>(*this),*this,this->fill(),p).failed() )
  1336.       err = ios_base::badbit;
  1337.     this->width(0);
  1338.   }
  1339.  
  1340.   #ifndef _RWSTD_NO_EXCEPTIONS
  1341.   }
  1342.   #endif
  1343.  
  1344.   #ifndef _RWSTD_NO_EXCEPTIONS
  1345.   catch(...)
  1346.   {
  1347.     bool flag = false;
  1348.     try {
  1349.            this->setstate(ios_base::badbit);
  1350.         }
  1351.     catch( ios_base::failure ) { flag= true; }
  1352.     if ( flag ) throw;
  1353.   }
  1354.   #endif
  1355.  
  1356.   if ( err ) this->setstate(err);
  1357.  
  1358.   return *this;
  1359. }
  1360.  
  1361. /*
  1362.  * basic_ostream& put(char_type)
  1363.  */
  1364.  
  1365. template<class charT, class traits>
  1366. basic_ostream<charT, traits>&
  1367. basic_ostream<charT, traits>::put(char_type c)
  1368. {
  1369.   ios_base::iostate err = 0; 
  1370.  
  1371.   #ifndef _RWSTD_NO_EXCEPTIONS
  1372.   try {
  1373.   #endif
  1374.  
  1375.   _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1376.  
  1377.   if(opfx)
  1378.      {
  1379.          if( traits::eq_int_type(rdbuf()->sputc(c),traits::eof()) )  
  1380.       err = ios_base::badbit;    
  1381.      }
  1382.  
  1383.   #ifndef _RWSTD_NO_EXCEPTIONS
  1384.   }
  1385.   #endif
  1386.  
  1387.   #ifndef _RWSTD_NO_EXCEPTIONS
  1388.   catch(...)
  1389.   {
  1390.     bool flag = false;
  1391.     try {
  1392.            this->setstate(ios_base::badbit);
  1393.         }
  1394.     catch( ios_base::failure ) { flag= true; }
  1395.     if ( flag ) throw;
  1396.   }
  1397.   #endif
  1398.  
  1399.   if ( err ) this->setstate(err);
  1400.  
  1401.   return *this;
  1402. }
  1403.  
  1404. /*
  1405.  * basic_ostream& write(const char_type *, streamsize)
  1406.  */
  1407.  
  1408. template<class charT, class traits>
  1409. basic_ostream<charT, traits>&
  1410. basic_ostream<charT, traits>::write(const char_type *s, streamsize n)
  1411. {
  1412.   ios_base::iostate err = 0; 
  1413.  
  1414.   #ifndef _RWSTD_NO_EXCEPTIONS
  1415.   try {
  1416.   #endif 
  1417.  
  1418.  if(s)
  1419.   {
  1420.     _TYPENAME basic_ostream<charT, traits>::sentry opfx(*this);
  1421.  
  1422.     if(opfx)
  1423.      {
  1424.        if(rdbuf()->sputn(s, n)!=n) 
  1425.         err = ios_base::badbit;
  1426.      }
  1427.   }
  1428.  else
  1429.   err = ios_base::badbit;
  1430.  
  1431.   #ifndef _RWSTD_NO_EXCEPTIONS
  1432.   }
  1433.   #endif
  1434.  
  1435.   #ifndef _RWSTD_NO_EXCEPTIONS
  1436.   catch(...)
  1437.   {
  1438.     bool flag = false;
  1439.     try {
  1440.            this->setstate(ios_base::badbit);
  1441.         }
  1442.     catch( ios_base::failure ) { flag= true; }
  1443.     if ( flag ) throw;
  1444.   }
  1445.   #endif
  1446.  
  1447.   if ( err ) this->setstate(err);
  1448.  
  1449.   return *this;
  1450. }
  1451.  
  1452.  
  1453. template<class charT, class traits>
  1454. basic_ostream<charT, traits>&
  1455. basic_ostream<charT, traits>::seekp(off_type off, ios_base::seekdir dir)
  1456. {
  1457.   #ifdef _RWSTD_MULTI_THREAD
  1458.    if ( rdbuf() )
  1459.     _RWSTDGuard guard(this->rdbuf()->buffer_mutex_);
  1460.   #endif
  1461.  
  1462.   if ( this->bad() ) return *this;
  1463.  
  1464.   if(rdbuf()->pubseekoff(off, dir, ios_base::out) == pos_type(off_type(-1)))
  1465.    this->setstate(ios_base::failbit);
  1466.   else
  1467.    clear(this->rdstate() & ~(ios_base::eofbit | ios_base::failbit));
  1468.  
  1469.   return *this;
  1470. }
  1471.  
  1472. template<class charT, class traits>
  1473. _TYPENAME basic_ostream<charT,traits>::pos_type
  1474. basic_ostream<charT, traits>::tellp()
  1475. {
  1476.   pos_type    p;
  1477.  
  1478.   #ifdef _RWSTD_MULTI_THREAD
  1479.    if ( rdbuf() )
  1480.     _RWSTDGuard guard(this->rdbuf()->buffer_mutex_);
  1481.   #endif
  1482.  
  1483.  if ( this->bad() ) return pos_type(-1);
  1484.  
  1485.   if((p = rdbuf()->pubseekoff(0, ios_base::cur,ios_base::out)) ==
  1486.      pos_type(off_type(-1)))
  1487.     this->setstate(ios_base::failbit);
  1488.  
  1489.   return p;
  1490. }
  1491.  
  1492.  
  1493. #ifndef _RWSTD_NO_NAMESPACE
  1494. }
  1495. #endif
  1496.  
  1497. #pragma option pop
  1498. #endif /* __OSTREAM_CC */
  1499.